﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

public class TeleportShotPrioritizedFollowPosition : PrioritizedFollowPosition
{
    private TeleportShotManager shotManager = null;
    private FollowTeleportShotState state = FollowTeleportShotState.Normal;

    private float postActionSeconds = 0.5f;
    private float postActionTime = 0.0f;

    private enum FollowTeleportShotState
    {
        Normal,
        ShotDestroyed,
        Complete
    }


    public TeleportShotPrioritizedFollowPosition(TeleportShotManager shotManager)
    {
        this.shotManager = shotManager;

    }

    public override void Update(float time)
    {
        switch (state) 
        {
            case FollowTeleportShotState.Normal:
                if (shotManager.IsDestroyed) 
                {
                    state = FollowTeleportShotState.ShotDestroyed;
                    Priority = PrioritizedFollowPosition.POST_ACTION;
                } 
                else 
                {
                    Priority = PrioritizedFollowPosition.STEERABLE_SHOT;
                    Position = shotManager.transform.position;
                }
                break;
            case FollowTeleportShotState.ShotDestroyed:
                postActionTime += time;
                if (postActionTime >= postActionSeconds) 
                {
                    state = FollowTeleportShotState.Complete;
                    Priority = PrioritizedFollowPosition.EXPIRED;
                }
                break;
        }

    }
}
